package com.gooapple.notepad.util;

import java.util.ArrayList;
import java.util.List;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

import com.gooapple.notepad.model.Picture;

public class MediaHelper {
	public static List<Picture> getPictures(Context context) {
		List<Picture> pictures = new ArrayList<Picture>();
		ContentResolver resolver = context.getContentResolver();
		Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
		Cursor cursor = resolver.query(uri, null, null, null, null);
		while (cursor.moveToNext()) {
			Picture picture = new Picture(cursor.getString(1), cursor
					.getString(3));
			pictures.add(picture);
		}
		return pictures;
	}

	public static int getPictureCount(Context context) {
		ContentResolver resolver = context.getContentResolver();
		Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
		Cursor cursor = resolver.query(uri, null, null, null, null);
		return cursor != null ? cursor.getCount() : 0;
	}
}
